Skip to main content

4.2 Software API and ROS

Kikobot C2 uses the same control architecture as C1: WebSocket on port 8080, motion planning and RViz from kikobot-backend c2, plus an optional camera stream on port 8081.

1. Starting the C2 stack​

kikobot-backend c2
ModeCommand
Desktop + RVizkikobot-backend c2
Headlessexport KIKOBOT_HEADLESS=1 && kikobot-backend c2
systemdsudo systemctl start kikobot-backend@c2

Environment:

VariablePurpose
KIKOBOT_C2_FIRMWARE_SCRIPTOverride UART firmware path
KIKOBOT_HEADLESS1 = no RViz window
ROS_DOMAIN_IDDefault 0 if unset; must match other ROS tools

Default firmware: /opt/kikobot/share/c2/kikobot_uart_with_gripper_loop.py

On-disk API reference​

AssetPath
Markdown/opt/kikobot/share/doc/WEBSOCKET_INTEGRATION_GUIDE.md
PDF/opt/kikobot/share/doc/WEBSOCKET_INTEGRATION_GUIDE.pdf
Example client/opt/kikobot/share/examples/kikobot_ws_client_example.py

2. WebSocket API (port 8080)​

3.1 Connection​

  • URL: ws://<robot-pc-ip>:8080
  • JSON messages; telemetry broadcast to all clients
  • No authentication — trusted LAN / VPN only

3.2 Handshake​

{
"type": "connected",
"message": "Connected to Kikobot C2 WebSocket Bridge",
"robot_profile": "c2",
"capabilities": {
"motion_planning_available": true,
"arc_booklet_available": true,
"hand_teaching_jog": true
}
}

3.3 C2 bring-up from your application​

1. (Admin) kikobot-backend c2
2. Connect WebSocket
3. { "type": "firmware_status" }
4. { "type": "start_firmware", "port": "/dev/ttyUSB0" }
5. Handle "joint_states" (~30 Hz)
6. { "type": "home" } or { "type": "motion_plan", "waypoints": [...] }

Firmware control:

{ "type": "start_firmware", "port": "/dev/ttyUSB0" }
{ "type": "stop_firmware" }
{ "type": "firmware_status" }

port is optional when auto-detect works; must be a safe /dev/tty… path.


3. Command reference​

typePurpose
homeC2 home via firmware + planner sync
jogJoint or Cartesian jog step
hand_teachingTeach, save pose, gripper, firmware home
motion_planMoveJ / MoveL / Arc / Circle
start_firmware / stop_firmware / firmware_statusUART bridge
save_motor_poseRead hardware joint positions
fk_requestForward kinematics
torque_release / torque_holdTorque off/on
hand_teach_points_recordTeach point recording toggle
set_do / get_diDigital I/O
start_waypoint_sequenceArc / booklet sequences
run_program / stop_programVisual program runner

Jog​

{
"type": "jog",
"axis": 0,
"direction": 1,
"mode": 0,
"step": 1.0,
"speed": 0.5
}

Hand teaching​

{ "type": "hand_teaching", "command": [2.0, 0.0, 0.0] }
teachsaverunAction
100Teach on
010Save pose
200Open gripper
020Close gripper
300Home (firmware)

C2 home joints (degrees)​

[92.53, 5.93, 102.73, 4.26, 90.07, 105.98]


4. Motion planning​

{
"type": "motion_plan",
"waypoints": [
{
"goal_joint_angles": [92.53, 5.93, 102.73, 4.26, 90.07, 105.98],
"goal_ee_pose": [],
"motion_type": 0,
"speed_fraction": 0.35,
"sleep_time": 0
},
{
"goal_joint_angles": [92.53, 5.93, 102.73, -13.22, 90.07, 105.98],
"goal_ee_pose": [],
"motion_type": 0,
"speed_fraction": 0.35,
"sleep_time": 0
}
]
}
motion_typeNameWaypoints per segment
0MoveJ2
1MoveL2 (TCP mm + deg)
2Arc3
3Circle3

Joint limits (deg): J1 ±165, J2 ±125, J3–J5 ±140, J6 ±175. Use margin below hard limits (e.g. J2 ≤ 124.95°).

Waypoint files: Keep goal joints within C2 planner limits. Do not reuse waypoint JSON from other robot models.

ROS CLI alternative (headless): With backend running and firmware up, move_joints.py in /opt/kikobot/share/c2/ can execute waypoint JSON on the same ROS domain — see HEADLESS_DOCKER_CLIENT_WORKFLOW.md.


5. Telemetry​

typeDescription
joint_statesjoint_names, angles (deg), angles_rad
jogging_feedbackActive jog
motion_planning_feedbackPlanner progress (joint_angles rad)
statusCommand success/failure
waypoint_sequence_status, arc_sequence_progressBooklet / arc automation

Example:

{
"type": "joint_states",
"joint_names": ["Revolute 1", "Revolute 2", "Revolute 3", "Revolute 4", "Revolute 5", "Revolute 6"],
"angles": [92.53, 5.93, 102.73, 4.26, 90.07, 105.98],
"angles_rad": [1.614, 0.103, 1.793, 0.074, 1.572, 1.849]
}

6. Camera & monitoring​

PortURL
8081http://<host>:8081/stream?topic=/camera/image_raw

Kikobot Studio monitoring page expects this stream when a camera node is running in the backend launch graph.


7. Python reference client​

pip install 'websockets>=12'
python3 /opt/kikobot/share/examples/kikobot_ws_client_example.py --host 127.0.0.1 status
python3 /opt/kikobot/share/examples/kikobot_ws_client_example.py --host 192.168.1.50 stream --seconds 10
python3 /opt/kikobot/share/examples/kikobot_ws_client_example.py --host 127.0.0.1 start-firmware --serial /dev/ttyUSB0
python3 /opt/kikobot/share/examples/kikobot_ws_client_example.py --host 127.0.0.1 demo-movej

The KikobotWebSocketClient class demonstrates concurrent handling of status replies and joint_states streams.


8. ROS 2 (advanced integrators)​

Packages (prebuilt in .deb)​

  • urdf_v3_description — C2 URDF / visualization
  • kikobot_motion_planner — trajectory planning and execution
  • custom_interfaces — motor pose and custom services

Topics & services (conceptual)​

The UART firmware node subscribes to trajectory and hand-teaching traffic and publishes feedback used by the bridge. Exact topic names match the C2 launch configuration started by kikobot-backend c2.

Domain ID: Shipped backend uses ROS domain 0 when ROS_DOMAIN_ID is unset. Do not mix domain 33 in one shell and 0 in another.

Development / source tree (maintainers)​

  • Workspace: Kikobot_C2_Software/
  • Dev launcher: start_c2_backend.sh
  • Operating guide: docs/1. Operating the C2 Full Stack.md

Customers on binary .deb installs do not need to compile ROS sources.


9. UART firmware capabilities​

Script: kikobot_uart_with_gripper_loop.py

  • Trajectory execution from ROS
  • Hand teaching commands
  • Gripper and signal motor control
  • Home position
  • Port listing: --list-ports, -p /dev/ttyUSB0, --interactive

When started via WebSocket start_firmware, logs go to /tmp/kikobot_firmware.log.


10. Kikobot Studio features (C2)​

  • Live 3D / RViz-backed visualization
  • Jog, hand teach, motion planning (MoveJ/L/Arc)
  • Monitoring page with camera
  • Waypoint sequences / industrial programming (feature flags per build)
  • Connects to the same 8080 API as external apps

11. Troubleshooting​

IssueFix
No connection on 8080kikobot-backend c2 or systemctl restart kikobot-backend@c2
context is invalidRestart backend
Motion server missing/tmp/kikobot_c2_display.log, kikobot-verify-backend
Firmware exitsWrong USB port, permissions, /tmp/kikobot_firmware.log
Joint limit errorsClamp waypoints to C2 planner limits
websockets import errorpip3 install --break-system-packages 'websockets>=12'
ss -ltn | grep 8080
tail -f /tmp/kikobot_websocket.log

12. Security​

Port 8080 binds on all interfaces without TLS or auth. Segment the robot network, use VPN, or tunnel via SSH.


  • [Installation and Integration](/docs/Kikobot C2/4.1 Installation and Integration)
  • [FAQ and Downloads](/docs/Kikobot C2/4.3 FAQ and Downloads)
  • [Kikobot C1 software and API](/docs/Kikobot C1/3.5 Software API and ROS) (shared protocol; different home pose & firmware)